import java.text.DecimalFormat;

public class Student extends User implements HaveName {

    private String name = "未设置";
    public ExamRecord examRecord = new ExamRecord();

    public Student() {
    }

    public Student(String userName, String password) {
        super(userName, password);
    }

    public Student(String userName, String password, String name) {
        super(userName, password);
        this.name = name;
    }

    public void showExamRecord() {
        DecimalFormat df = new DecimalFormat("#.00");
        System.out.println("------------------");
        System.out.println("     考试记录");
        System.out.println("------------------");
        System.out.println(" 考试总次数: " + examRecord.examTimes );
        System.out.println(" 考试平均分: " + df.format(examRecord.averageScore));
        System.out.println(" 答题数: " + examRecord.answeredQuestionNumber );
        System.out.println(" 正确率: " + df.format(examRecord.accuracy*100)+"%");
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Student{" + super.toString() +
                ", name='" + name + '\'' +
                '}';
    }
}
